import request from "@/api/config";
import { AxiosPromise } from 'axios';
import {PORT} from "@/leadmall/api/config/servicePort";
import { KnowledgeDocVO, KnowledgeDocForm, KnowledgeDocQuery } from '@/leadmall/api/knowledgeDoc/types';

/**
 * 查询知识库文档列表
 * @param query
 * @returns {*}
 */

export const listKnowledgeDoc = (query?: KnowledgeDocQuery): AxiosPromise<KnowledgeDocVO[]> => {
  return request({
    url: PORT +'/leadmall/knowledgeDoc/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询知识库文档详细
 * @param id
 */
export const getKnowledgeDoc = (id: string | number): AxiosPromise<KnowledgeDocVO> => {
  return request({
    url: PORT +'/leadmall/knowledgeDoc/' + id,
    method: 'get'
  });
};

/**
 * 新增知识库文档
 * @param data
 */
export const addKnowledgeDoc = (data: KnowledgeDocForm) => {
  return request({
    url: PORT +'/leadmall/knowledgeDoc',
    method: 'post',
    data: data
  });
};

/**
 * 修改知识库文档
 * @param data
 */
export const updateKnowledgeDoc = (data: KnowledgeDocForm) => {
  return request({
    url: PORT +'/leadmall/knowledgeDoc',
    method: 'put',
    data: data
  });
};

/**
 * 删除知识库文档
 * @param id
 */
export const delKnowledgeDoc = (id: string | number | Array<string | number>) => {
  return request({
    url: PORT +'/leadmall/knowledgeDoc/' + id,
    method: 'delete'
  });
};
